import React from 'react';
import * as asyncLoad from '../util/asyncLoad';
import { hrmFiles } from '../constants/fileConfig';
import Loading from './Loading';

export default class HrmEmployeeSetting extends React.Component{
    constructor(){
        super();
        this.state = {
            hasLoad: false,
            store: null
        };
    }
    componentDidMount(){
        const init = () =>{
            const { closeFun } = this.props;
            const { HrmNewEmployeeSetStore } = window.weaHrmEnginePublic;
            const store = new HrmNewEmployeeSetStore();
            store.setCloseDialogFun(closeFun);
            this.setState({hasLoad:true, store:store});
        }
        asyncLoad.asyncLoadModule('hrm', hrmFiles, init);
    }
    render(){
        const { hasLoad,store } = this.state;
        if(hasLoad){
            const { hrmid } = this.props;
            const { HrmNewEmployeeSet } = window.weaHrmEnginePublic;
            if(hrmid === false){
                store.setVisible(false);
            }else{
                store.setHrmId(hrmid);
                store.setVisible(true);
            }
            return (
                <HrmNewEmployeeSet ecId={`${this && this.props && this.props.ecId || ''}_HrmNewEmployeeSet@6w8oow`} hrmNewEmployeeSetStore={store} />
            )
        }else{
            return (<Loading ecId={`${this && this.props && this.props.ecId || ''}_Loading@1oe54e`} />);
        }
    }
}